package com.wangdong.wdutils.utils;

import android.content.Context;

/**
 *  把 colors 中的资源 id 转成 String #000000 字符串
 */
public class DLColorUtils {

    public static String changeColor(Context context, int id){
        StringBuilder stringBuffer = new StringBuilder();
        int color = context.getResources().getColor(id);
        int red = (color & 0xff0000) >> 16;
        int green = (color & 0x00ff00) >> 8;
        int blue = (color & 0x0000ff);

        stringBuffer.append("#");
        stringBuffer.append(Integer.toHexString(red));
        stringBuffer.append(Integer.toHexString(green));
        stringBuffer.append(Integer.toHexString(blue));
        return stringBuffer.toString();
    }
}
